import 'package:flutter/material.dart';
import 'package:kalaqia_flutter_go/first_page.dart';

class AppPage extends StatefulWidget {
  @override
  _AppPageState createState() => _AppPageState();
}

class _AppPageState extends State<AppPage> with SingleTickerProviderStateMixin {
  TabController controller;
  List<Widget> myTabs = [];
  static List tabData = [
    {'text': '业界动态', 'icon': new Icon(Icons.language)},
    // {'text': 'WIDGET', 'icon': new Icon(Icons.extension)},
    // {'text': '组件收藏', 'icon': new Icon(Icons.favorite)},
    // {'text': '关于手册', 'icon': new Icon(Icons.import_contacts)}
  ];

  @override
  void initState() {
    super.initState();
    controller = new TabController(initialIndex: 0, vsync: this, length: 1);
    for (var i = 0; i < tabData.length; i++) {
      myTabs.add(new Tab(
        text: tabData[i]['text'],
        icon: tabData[i]['icon'],
      ));
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: buildSearchInput(context),
      ),
      body: TabBarView(
        controller: controller,
        children: <Widget>[FirstPage()],
      ),
      bottomNavigationBar: Material(
        color: const Color(0xFFF0EEEF),
        child: SafeArea(
          child: Container(
            height: 65.0,
            decoration: BoxDecoration(
              color: const Color(0xFFF0F0F0),
              boxShadow: [
                BoxShadow(
                  blurRadius: 3.0,
                  color: const Color(0xFFd0d0d0),
                  spreadRadius: 2.0,
                  offset: Offset(-1.0, -1.0),
                )
              ],
            ),
            child: TabBar(
              controller: controller,
              indicatorColor: Theme.of(context).primaryColor,
              indicatorWeight: 3.0,
              tabs: myTabs,
            ),
          ),
        ),
      ),
    );
  }

  buildSearchInput(BuildContext context) {
    return SearchInput();
  }
}

class SearchInput extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 40.0,
    );
  }
}
